<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn">
<head>
<base href="<c:url value='/'/>"/>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>邀请码管理</title>
    <link rel="stylesheet" href="resources/static/css/pintuer.css">
    <link rel="stylesheet" href="resources/static/css/admin.css">
    <script src="resources/static/js/jquery.js"></script>
    <script src="resources/static/js/pintuer.js"></script>
    <script src="resources/static/js/esl/esl.js"></script>
    <script src="resources/static/js/echarts.js"></script>
    <script type="text/javascript">
       function move(currPage,pageSize){
    	   //var pageSize=document.getElementById("pageSize").value;
    	   
    	   var url="invcode/listinvcode?currPage="+currPage;
    	   if(pageSize!=undefined){
    		   url+="&pageSize="+pageSize;
    	   }
    	   var queryic=document.getElementById("inv").value;
    	   if(queryic!=undefined){
    		   url+="&queryic="+queryic;
    	   }
    	   location.href=url;
       }
       
       function deleteic(invid){
    	   $.get("invcode/deleteic?invid="+invid,function(data){
    	       var jsonObj=data;
    	       if(jsonObj.result){
    	    	   alert(jsonObj.result);
    	    	   var currPage='${page.currPage}';
    	    	   var pageSize='${page.pageSize}';
    	              move(currPage,pageSize);
    	            }
    	     });
    	   
       }
       
       function reicvalid(invid){
    	   $.get("invcode/reicvalid?invid="+invid,function(data){
    	       var jsonObj=data;
    	       if(jsonObj.result){
    	    	   alert(jsonObj.result);
    	    	   var currPage='${page.currPage}';
    	    	   var pageSize='${page.pageSize}';
    	              move(currPage,pageSize);
    	            }
    	     });
       }
    </script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder">邀请码管理</strong></div>
    <div class="padding border-bottom clearfix">
        <button class="button button-little bg-blue">导出为Excel</button>
        <button class="button button-little bg-blue">
            <a href="invcode/preaddinvcode">新增邀请码</a>
        </button>
        <button class="button button-little bg-blue">
            <a href="invcode/preaddtypecode"> 新增邀请码类别</a>
        </button>
    </div>
    <div class="padding border-bottom clearfix">
        <form method="post" class="form-x uI" action="invcode/listinvcode" >
            <div class="form-group form-group2" style="margin-bottom: 0;padding-bottom: 0">
                <div class="label" style="width: 120px;">
                    <label>邀请码：</label>
                </div>
                <div class="field" style="width: 70%;">
                    <input id="inv" type="text" class="input w50" name="queryic" value="${inv }" />
                </div>
            </div>
            <div class="form-group form-group2" style="margin-bottom: 0">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main" style="float: right;padding: 10px 50px;margin-right:150px;" type="submit"> 查询</button>
                </div>
            </div>
        </form>
    </div>
    <div class="body-content">
        <!--<div class="panel-head"><strong class="icon-reorder"> 请假单据列表</strong></div>-->
        <table class="table table-hover text-center">
            <tr>
                <th width="">序号</th>
                <th width="">邀请码</th>
                <th width="">单位</th>
                <th width="">已使用时间</th>
                <th width="">状态</th>
                <th width="">激活时间</th>
                <th width="">操作</th>
            </tr>
            
             <c:forEach items='${invcodeInfoList }' var="inv" varStatus="status">
         <tr>
           <td>${status.index+1}</td>
           <td>${inv.invcode }</td>
           <td></td>
           <c:choose>
               <c:when test="${inv.status eq 1 }">
                <td>${inv.usedtime }</td>
               </c:when>
               <c:when test="${inv.status eq 2 }">
                 <td>---</td>
               </c:when>
           </c:choose>
         <td>${inv.status }</td>
         <td>${inv.registertime }</td>
            <c:choose>
             <c:when test="${inv.status==1 }">
            <td>
                    <a class="text-main" href="invcode/toprolongic?invid=${inv.invid}">延长时限</a>
                    <a class="text-main" href="invcode/geticregidetail?invid=${inv.invid}">查看</a>
                    <a class="text-main" href="invcode/toupdateic?invid=${inv.invid}">修改</a>
                </td>
                </c:when>
                <c:otherwise>
               <td>
                    <span class="text-main"><a href="javascript:void(0)" onclick="reicvalid(${inv.invid})">恢复</a></span>
                    <span class="text-main margin-little-left"><a href="javascript:void(0)" onclick="deleteic(${inv.invid})">删除</a></span>
                    <a class="text-main margin-little-left" href="invcode/geticregidetail?invid=${inv.invid}">查看</a>
                    <a class="text-main" href="invcode/toupdateic?invid=${inv.invid}">修改</a>
                </td>
                </c:otherwise>
              </c:choose>
         </tr>
        
       </c:forEach>
           
            
            <tr>
                <td colspan="12">
                    <div class="pagelist">
                    <a href="javascript:move(${page.currPage-1 },${page.pageSize})">上一页</a> 
                    <span class="current"> <a  href="javascript:move(1,${page.pageSize})">1</a></span>
                    <a href="javascript:move(2,${page.pageSize})">2</a>
                    <a href="javascript:move(3,${page.pageSize})">3</a>
                    <a href="javascript:move(${page.currPage+1 },${page.pageSize})">下一页</a>
                    <a href="javascript:move(${page.totalPage },${page.pageSize})">尾页</a></div>
                </td>
            </tr>

        </table>
    </div>
</div>


<script src="resources/static/js/tjfx-bar.js"></script>
</body>
</html>